﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DisplayBoardInfo.Server.Entities
{
    public class Role : Entity
    {
        private Model.Role role;

        /// <summary>
        /// Role entity. Only to read.
        /// </summary>
        /// <param name="role">Role to wrapping</param>
        public Role(Model.Role role)
        {
            this.role = role;
        }

        public override void Refresh()
        {
            //Role shouldn't be modify, so refresh is no nessesery
        }

        public override void Save()
        {
            //Don't save anything, all is read-only
        }

        /// <summary>
        /// Gets name of role.
        /// </summary>
        public string Name
        {
            get 
            {
                return role.Name;
            }
        }

        /// <summary>
        /// Gets description of role.
        /// </summary>
        public string Description
        {
            get 
            {
                return role.Description;
            }
        }

        /// <summary>
        /// Gets users belongs to role 
        /// </summary>
        public IEnumerable<User> Users
        {
            get 
            {
                List<User> result = new List<User>();
                foreach (Model.User item in role.Users)
                {
                    result.Add(new User(item.Username));
                }
                return result;
            }
        }
    }
}
